package com.wxapp.sale.service.controller.client;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wxapp.common.constant.pojo.vm.ResultVm;
import com.wxapp.common.core.filter.except.ThrowMyException;
import com.wxapp.sale.api.pojo.vm.goods.PGoodsAllFileDetailVm;
import com.wxapp.sale.api.pojo.vm.goods.PGoodsDetailVm;
import com.wxapp.sale.api.pojo.vm.goods.PGoodsPageVm;
import com.wxapp.sale.api.pojo.vo.goods.QGoodsPageVo;
import com.wxapp.sale.service.service.GoodsService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author lgl
 */
@RestController
@RequestMapping("client/goods")
@Tag(name = "商品")
@RequiredArgsConstructor
public class GoodsClientController {
    private final GoodsService goodsService;

    @PostMapping("page")
    @Operation(summary ="获取商品列表")
    public ResultVm<Page<PGoodsPageVm>> getGoodsPage(@RequestBody QGoodsPageVo qPageVo) {
        return goodsService.page(qPageVo, null);
    }
    @GetMapping("detail/{id}")
    @Operation(summary ="获取商品列表")
    public ResultVm<PGoodsDetailVm> detail(@PathVariable String id) throws ThrowMyException {
        return goodsService.detail(id);
    }

    @GetMapping("getFilesDetail/{id}")
    @Operation(summary ="添加商品附件")
    public ResultVm<List<PGoodsAllFileDetailVm>> getFilesDetail(@PathVariable String id) {
        return goodsService.getFilesDetail(id);
    }

}
